//
//  ProvinceAndCity.m
//  YaoHeAPP
//
//  Created by mac on 15/12/30.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "ProvinceAndCity.h"
#import "DatabaseTool.h"
#import "sheng.h"
#import "city.h"
@implementation ProvinceAndCity



//输入省ID返回省名
+(NSString*)inputShengID:(NSString*)str
{
    NSString*shengName;
    NSArray*shengArray=[DatabaseTool querySheng];
    for (NSInteger i=0; i<shengArray.count;i++) {
        sheng*name=shengArray[i];
        if ([name.shengID integerValue]==[str integerValue]) {
            shengName=name.shengName;
            break;
        }
    }
    return shengName;
}

//输入ID返回市名
+(NSString*)inputCityID:(NSString *)str
{
    NSString*cityName;
    NSArray*shiArray=[DatabaseTool queryCity];
    for (NSInteger i=0; i<shiArray.count; i++) {
        city*name=shiArray[i];
        if ([name.cityID integerValue]==[str integerValue]) {
            cityName=name.cityName;
            break;
        }
    }
    return cityName;
}

//输入省名返回省ID
+(NSString*)inputShengName:(NSString*)str
{
    NSString*shengID;
    NSArray*shengArray=[DatabaseTool querySheng];
    for (NSInteger i=0; i<shengArray.count;i++) {
        sheng*name=shengArray[i];
        if ( [name.shengName isEqual:str]) {
            shengID=name.shengID;
            break;
        }
    }
    return shengID;
}

//输入市名返回市ID
+(NSString*)inputCityName:(NSString*)str
{
    NSString*cityID;
    NSArray*shiArray=[DatabaseTool queryCity];
    for (NSInteger i=0; i<shiArray.count; i++) {
        city*name=shiArray[i];
        if ([name.cityName isEqual:str]) {
            cityID=name.cityID;
            break;
        }
    }
    return cityID;
}




/*
-(void)query
{
    NSArray*shiArray=[DatabaseTool queryCity];
    NSString *shengid;
    for (NSInteger i=0; i<shiArray.count; i++)
    {
        city*city=shiArray[i];
        shengid=city.shengID;
        if([[_dic allKeys] containsObject:shengid])
        {
            NSMutableArray*citys=[_dic valueForKey:shengid];
            [citys addObject:city];
        }
        else
        {
            NSMutableArray*citys=[NSMutableArray array];
            [citys addObject:city];
            [_dic setObject:citys forKey:shengid];
        }
    }

}
*/



@end
